#! /bin/bash

# unpacks and runs standard regression tests for systemc to '$SYSCPAR_ROOT/tests/systemc_tests-2.2.0'
#
#
# requires:
#	$SYSCPAR_ROOT/downloads/systemc_tests-2.2.0.tar
#
# type --help for usage
# most of the command-line arguments are redirected to the testing script; run with no args to see usage

name='systemc_tests-2.2.0'
usage="$0 --help \t\t - shows this\n$0 {path|ver} [params] - runs regression test suite with SYSTEMC_HOME=<path> or SYSTEMC_HOME=\$SYSCPAR_ROOT/code/<ver>/systemc-2.2.0 and testing parameters as specified\n$0\t\t\t - shows available testing parameters\n$0 --clean\t\t - removes systemc-2.2.0 regression test suite installed by this script"

case $1 in '-h'|'-help'|'--help')
	echo  -e $usage
	exit;;
esac
[[ $1 == "--clean" ]] && { rm -rf $SYSCPAR_ROOT/tests/$name; echo 'cleaned'; exit 0; }

if [[ -d $SYSCPAR_ROOT/code/$1/systemc-2.2.0 ]]
then
	systemc_home=$SYSCPAR_ROOT/code/$1/systemc-2.2.0
else
	systemc_home=$1
fi
shift

cp $SYSCPAR_ROOT/downloads/$name.tar $SYSCPAR_ROOT/tests/
cd $SYSCPAR_ROOT/tests/
tar -xf ./$name.tar
rm -f ./$name.tar
cd ./$name
mkdir -p ./tmp_tests
cp -r ./tests ./tmp_tests		#tests are not to be run from original tests directory, see regression test suite readme
SYSTEMC_TESTS=${SYSTEMC_TESTS:-./tmp_tests}
env CXX=${CXX:-g++} SYSTEMC_HOME=$systemc_home ./scripts/verify.pl $*
